﻿using System;
using System.Collections.Generic;
using XCI.Sys.Model;
using XCI.Core;
using XCI.Windows.Extensions;

namespace XCI.Sys.Service
{
    /// <summary>
    /// 系统锁定用户服务
    /// </summary>
    public class LockUserService : BaseService<LockUserModel>
    {
        public static readonly LockUserService Instance = new LockUserService();
        protected override string RootUrl => "/api/sys/lockUser/";

        /// <summary>
        /// 添加锁定用户
        /// </summary>
        /// <param name="account">用户账号</param>
        public bool Add(string account)
        {
            var url = GetUrl("add", account);
            return SysRuntime.Api.PostAsMessage(url).EnsureSuccess().Success;
        }

        /// <summary>
        /// 移除锁定用户
        /// </summary>
        /// <param name="account">用户账号</param>
        public bool Remove(string account)
        {
            var url = GetUrl("remove", account);
            return SysRuntime.Api.PostAsMessage(url).EnsureSuccess().Success;
        }

        /// <summary>
        /// 查询单个锁定用户
        /// </summary>
        /// <param name="account">用户账号</param>
        public LockUserModel Get(string account)
        {
            var url = GetUrl("get", account);
            return SysRuntime.Api.Post<LockUserModel>(url).EnsureSuccess().Data;
        }

        /// <summary>
        /// 查询锁定用户列表
        /// </summary>
        public List<LockUserModel> Query()
        {
            var url = GetUrl("query");
            return SysRuntime.Api.Post<List<LockUserModel>>(url).EnsureSuccess().Data;
        }

        /// <summary>
        /// 导出锁定用户列表
        /// </summary>
        public byte[] Export()
        {
            return ExportCore();
        }
    }
}
